package br.com.center.loja.ws.dto;

import java.io.Serializable;

import br.com.center.loja.model.TypeCity;

public class CityDTO implements Serializable{

	private static final long serialVersionUID = 1L;

	private Long code;
	private String name;
	private String state;
	private String zipCode;
	private TypeCity typeCity;
	private CityDTO major;
	
	public Long getCode() {
		return code;
	}

	public void setCode(Long code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = removeFormat(zipCode);
	}
	
	private String removeFormat(String zipCode){
		return zipCode.replaceAll("-", "");		
	}

	public TypeCity getTypeCity() {
		return typeCity;
	}

	public void setTypeCity(TypeCity typeCity) {
		this.typeCity = typeCity;
	}

	public CityDTO getMajor() {
		return major;
	}

	public void setMajor(CityDTO major) {
		this.major = major;
	}
	
	@Override
	public String toString() {
		StringBuilder result = new StringBuilder();
		
		result.append(getCode())
		      .append(" - ")
		      .append(getName());
		
		return result.toString();
	}
}
